package com.kakaxi.mybilibili.module.home.consider.view;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;

import com.github.czy1121.view.RoundButton;
import com.kakaxi.mybilibili.R;
import com.kakaxi.mybilibili.base.BaseFragment;
import com.kakaxi.mybilibili.bean.EventBusObject;
import com.kakaxi.mybilibili.module.user.view.LoginActivity;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.ButterKnife;

import static android.app.Activity.RESULT_OK;

/**
 * 关注主页面碎片
 * Created by kakaxi on 16/10/11.
 */

public class ConsiderHomeFragment extends BaseFragment {

    @BindView(R.id.roubtn_consider_home_login)
    RoundButton loginBtn;

    public static ConsiderHomeFragment newInstance() {
        return new ConsiderHomeFragment();
    }

    @Override
    protected int getContentViewId() {
        return R.layout.fragment_consider_home;
    }

    @Override
    protected void setupViews(ViewGroup viewGroup) {
        ButterKnife.bind(this, viewGroup);

        loginBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                goActivityAndResult(LoginActivity.class, LoginActivity.ACT_REQUEST_CODE);
            }
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case LoginActivity.ACT_REQUEST_CODE: { // 登录界面返回结果
                if (resultCode == RESULT_OK) { // 登录成功
                    EventBusObject object = new EventBusObject(EventBusObject
                            .EVENT_MAIN_ACT_UPDATE_USER_INFO, "");
                    EventBus.getDefault().post(object);
                }
                break;
            }
        }
    }
}
